
<!--js date picker-->

<link href="<?php echo base_url(); ?>./css/css_datepicker/jquery.ui.all.css" rel="stylesheet" type="text/css" />  
<script type="text/javascript" src="<?php echo base_url(); ?>jscripts/js_datepicker/jquery-1.7.2.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>jscripts/js_datepicker/jquery.ui.core.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>jscripts/js_datepicker/jquery.ui.datepicker.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>jscripts/js_datepicker/jquery.ui.widget.js"></script>

<!--end js date picker-->


<!--the start of function date picker-->

<script language="javascript" type="text/javascript">
    $(function() {
        $( ".datepicker" ).datepicker({
            changeMonth: true,
            changeYear: true,
            dateFormat: 'yy:mm:dd' 
        });
    });
           
</script>

<!--the end of function date picker-->

<?php
//===========this is condition for showing form validation==============//

if ($this->session->userdata('ms_error')) {
    echo message($this->session->userdata('ms_error'), "error");
    $this->session->unset_userdata("ms_error");
} else if ($this->session->userdata('invalid_sal')) {
    echo $this->session->userdata('invalid_sal');
    echo $this->session->unset_userdata('invalid_sal');
}

//==========this is condition for the end of form validation============//



$this->db->where('car_type_id', 1);
$cardname1 = $this->db->get('tbl_card');
$this->db->where('car_type_id', 2);
$cardname2 = $this->db->get('tbl_card');
$option1 = "";
$option2 = "";
$option1.='<option value="">-Please select-</option>';
foreach ($cardname1->result() as $value) {
    $option1.='<option value="' . $value->car_id . '">' . $value->car_name . '</option>';
}
$option2.='<option value="">-Please select-</option>';
foreach ($cardname2->result() as $values) {
    $option2.='<option value="' . $values->car_id . '">' . $values->car_name . '</option>';
}

$this->db->where('price_K');
$prcekhmer = $this->db->get('tbl_pricecard');
?>

<!--this is start of style sheet-->

<style type="text/css">
    fieldset {
        display: none;
        margin: 10px; 
    }
    span{color: red;}
</style>

<!--this is end  of style sheet-->

<div style="margin: 0 auto;width: 98%;height: auto;border: 0px #ccc solid;text-align: center;font-size: 20px;color:#4F815C;">Sale Card</div><br/>
<div style="margin: 0 auto;width:93%;height: auto;border: 1px #ccc solid; padding:20px 15px 20px 15px;-moz-border-radius:10px;">
    <div style="float: right; border: 0px #ccc solid;"><?php echo anchor('sale_management/sale_card', img('images/user_images/cancel.png')); ?></div>
    <?php echo form_open('sale_management/add_card', array('name' => 'frmstudent', 'onsubmit' => 'return check_student()', 'method' => 'post')); ?>
    <?php
    echo '<table border="0" align="center" style="font-weight: lighter;font-size: 14px; celspacing="0" cellpadding="3" height="auto">';
    echo '<tr>';
    $query_student = $this->db->query('SELECT * from tbl_student');
    echo '<td>CustomerName<span>*</span></td>';
    echo '<td>';
    $select = '<select name="student" id="student">';
    $select.='<option value="0">--Select Customer Name--</option>';
    foreach ($query_student->result() as $rows) {
        $select.='<option value="' . $rows->stu_id . '">' . $rows->stu_name . '</option>';
    }
    $select.='</select>' . form_error('student');
    echo $select;
    echo'</td>';
    echo '</tr>';
    echo '</tr>';
    echo '<tr>';
    $query_cardType = $this->db->query('SELECT * from tbl_car_type');
    echo '<td>CardType</td>';
    echo '<td>';
    $select = '<select name="card_type" id="type">';
    $select.='<option value="0">--Select Card Type--</option>';
    foreach ($query_cardType->result() as $row) {
        $select.='<option value="' . $row->car_type_id . '">' . $row->car_type_name . '</option>';
    }
    $select.='</select>' . form_error('card_type');
    echo $select;
    echo '</td></tr>';
    echo '<tr>';
    echo '<td>CardName</td>';
    echo '<td>';
    $select = '<select name="card" id="card">';
    $select.='<option value="0">--Select--</option>';
    $select.='</select>';
    echo $select;
    echo'</td></tr>';
    echo '<td>PriceCard</td>';
    //  foreach ($data->result() as $value){
    echo '<td>' . form_input(array('name' => 'txt_price', 'id' => 'txt_price', 'readonly' => '', 'value' => $this->input->post('txt_price') ? $this->input->post('txt_price') : " ")) . '$</td>';
    echo '<tr>';
    echo '<td>SaleQuantity</td>';
    echo '<td>' . form_input(array('name' => 'txt_quantity', 'value' => $this->input->post('txt_quantity') ? $this->input->post('txt_quantity') : " ")) . form_error('txt_quantity');
    '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td>Payment</td>';
    echo '<td>' . form_input(array('name' => 'txt_payment', 'value' => $this->input->post('txt_payment') ? $this->input->post('txt_payment') : " ")) . form_error('txt_payment') . '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td>SaleDate<span>*</span></td>';
    echo '<td>';
    ?>
    <input type="text" name="txt_saleDate" class="datepicker" value="<?php echo ($this->input->post("txt_saleDate")) ? $this->input->post("txt_saleDate") : "" ?>" /><?php echo form_error('txt_saleDate'); ?>
    <?php
    // echo '<td>' . form_input(array('name' => 'txt_saleDate', 'id' => 'formDate','readonly'=>'',img('images/calendar.gif') )) . '</td>';
    echo '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td>Descripton</td>';
    echo '<td> ' . form_textarea(array('name' => 'txt_description', 'rows' => '8', 'cols' => '40', 'value' => $this->input->post('txt_description') ? $this->input->post('txt_description') : " ")) . '</td>';
    echo'</tr>';

    echo '<tr>';
    echo '<td></td>';
    echo '<td>' . form_input(array('name' => 'btn_submit', 'type' => 'submit', 'value' => 'Submit')) . form_input(array('type' => 'reset', 'value' => 'Reset')) . '</td>';
    //echo '<td>'.anchor(array('type'=>'button','students/manager'=>'Cansel')).'</td>';
    echo '</tr>';
    ?>
</td>
</tr>

</table>
<?php echo form_close(); ?>
</div>

<!--this is ajax for compare using price type-->


<script type="text/javascript">
    window.onload = function(){
        new JsDatePick({
            useMode:2,
            target:"inputField",
            dateFormat:"%d-%M-%Y"

        });
    };

    $(function(){

        $(function(){
            $('#type').change(function(){
                var typ_id = $(this).val();

                $.ajax({
                    type: 'POST',
                    url: "<?php echo base_url() . 'sale_management/getCardByType'; ?>",
                    data: {
                        type_id: typ_id
                    },
                    success: function(opt){

                        $('#card').html(opt);

                    }
                });
            });
        });

        $(function(){
            $('#card').change(function(){
                var card_id = $(this).val();
                var stu_id = $('#student').val();
                $.ajax({
                    type: 'POST',
                    url: "<?php echo base_url() . 'sale_management/getCardPrice'; ?>",
                    data: {
                        //post student_id and card_id
                        stuid: stu_id,
                        cardid: card_id
                    },
                    success: function(price){

                        $('#txt_price').val(price);

                    }
                });
            });
        });
    });


</script>

<!--this is the end of  ajax for compare using price type-->